<template>
  <div style="text-align: center">
    <div style="display: inline; margin-left: 3%">
      <h4 style="display: inline">姓名:</h4>
      <input
        type="text"
        style="display: inline; margin-left: 7%"
        v-model="uname"
      />
    </div>
    <div style="margin-top: 3%; margin-left: 3%">
      <h4 style="display: inline">性别:</h4>
      <input
        type="text"
        style="display: inline; margin-left: 7%"
        disabled="disabled"
        v-model="sex"
      />
    </div>
    <div style="margin-top: 3%; margin-left: 3%">
      <h4 style="display: inline">年龄:</h4>
      <input
        type="text"
        style="display: inline; margin-left: 7%"
        v-model="age"
      />
    </div>
    <div style="margin-top: 3%; margin-left: 3%">
      <h4 style="display: inline">证件类型:</h4>
      <input
        type="text"
        style="display: inline; margin-left: 4%"
        disabled="disabled"
        value="居民身份证"
      />
    </div>
    <div style="margin-top: 3%; margin-left: 3%">
      <h4 style="display: inline">证件号码:</h4>
      <input
        type="text"
        style="display: inline; margin-left: 4%"
        disabled="disabled"
        v-model="icd"
      />
    </div>
    <div style="margin-top: 3%; margin-left: 3%">
      <h4 style="display: inline">联系电话:</h4>
      <input
        type="text"
        style="display: inline; margin-left: 4%"
        v-model="tel"
      />
    </div>
    <div style="margin-top: 3%; margin-left: 3%">
      <h4 style="display: inline">居住地址:</h4>
      <input
        type="text"
        style="display: inline; margin-left: 4%"
        v-model="address"
      />
    </div>
    <div>
      <el-button
        type="primary"
        lock-scroll
        @click.native.prevent="updateInfo()"
        style="margin-left: 10%; margin-top: 10px"
        >修改信息</el-button
      >
    </div>
  </div>
</template>
<script>
import axios from "axios";
import commons from "../../../assets/commons";
export default {
  data() {
    return {
      // id: "",
      uname: "",
      sex: "",
      age: "",
      icd: "",
      tel: "",
      address: "",
    };
  },
  methods: {
    findUser() {
      console.log(this.$store.state.person);
      this.uname = this.$store.state.person.name;
      this.sex = this.$store.state.person.sex;
      this.age = this.$store.state.person.age;
      this.icd = this.$store.state.person.icd;
      this.tel = this.$store.state.person.tel;
      this.address = this.$store.state.person.address;
    },

    //修改信息
    updateInfo() {
      let user = {
        id: this.$store.state.person.id,
        name: this.uname,
        age: this.age,
        tel: this.tel,
        address: this.address,
      };
      console.log(user);
      axios
        .post(commons.baseUrl + "user/user/updateInfo",user)
        .then((resp) => {
          console.log(resp);
          this.$message(resp.data.message);
        });
    },
  },
  mounted() {
    this.findUser();
  },
  computed: {},
};
</script>
<style scoped></style>
